//
//  WBWelcomeViewController.swift
//  WeiBo
//
//  Created by chenguanglei on 16/11/28.
//  Copyright © 2016年 itheima. All rights reserved.
//

import UIKit

class WBWelcomeViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        view.backgroundColor = UIColor.white
        
        setupUI()
    }

   
    
    override func viewDidAppear(_ animated: Bool) {
        
       
        animation()
        
    }
    
    
    private func animation (){
    
    
        imageV .snp_updateConstraints { (make) in
            
            make.centerY.equalTo(view.snp_centerY).offset(-250)
            
        }
        
        
        
        UIView.animate(withDuration: 1.5, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0, options: [], animations: {
           
            self.view.layoutIfNeeded()
            
        }) { (Bool) in
            
            UIView .animate(withDuration: 1, animations: {
                
                self.messageLabel.alpha = 1
                
                }, completion: { (Bool) in
                    
                  
                    NotificationCenter.default.post(name: NSNotification.Name(rawValue: kNotificationChangeVC), object: nil)
                    
                    
                    
            })
            
        }
        
    
    
    }
    
    
    
    private func setupUI (){
    
        view.addSubview(imageV)
        view.addSubview(messageLabel)
        
        messageLabel.alpha = 0
        
        imageV .snp_makeConstraints { (make) in
            
            make.centerX.equalTo(view.snp_centerX)
            make.centerY.equalTo(view.snp_centerY)
            
        }
        
    
        messageLabel.snp_makeConstraints { (make) in
            
            make.centerX.equalTo(view.snp_centerX)
            make.top.equalTo(imageV.snp_bottom).offset(10)
            
        }
        
        
    }
    
    
    
    private lazy var imageV : UIImageView = {
    
        
        let imageV = UIImageView.init(image: UIImage.init(named: "avatar_default_big"))
        
        imageV.layer.cornerRadius = 85 * 0.5
        imageV.layer.masksToBounds = true
        imageV.layer.borderColor = UIColor.lightGray.cgColor
        imageV.layer.borderWidth = 1
        
        imageV.sizeToFit()
        
        
        return imageV
    
    }()
    
    
    private lazy var messageLabel : UILabel = UILabel(labelText: "欢迎归来", labelFont: 16, textColor: UIColor.lightGray, align: NSTextAlignment.center)
    
}
